from time import sleep

from selenium import webdriver
from selenium.webdriver.common.by import By

# 初始化驱动
driver = webdriver.Chrome()
# 打开网页
driver.get("https://www.baidu.com/")
# 设置隐式等待
driver.implicitly_wait(15)
# 输入内容
driver.find_element(By.NAME,'wd').send_keys('白嘉诚')
# 点击搜索按钮
driver.find_element(By.ID,'su').click()
sleep(3)
# 滚动条向下
win1 = 'window.scrollBy(0,500)'     # js脚本
driver.execute_script(win1)
sleep(5)
# 滚动条向上
win2 = 'window.scrollBy(0,-500)'
driver.execute_script(win2)
sleep(2)
# 滚动条向右
win3 = 'window.scrollBy(500,0)'
driver.execute_script(win3)
sleep(2)
# 滚动条向左
win4 = 'window.scrollBy(-500,0)'
driver.execute_script(win4)

sleep(10)


